<template>
    <!-- 默认值 -->
    <div class="form-block">
        <label>默认值</label>
        <input class="input-text" type="text" v-model="defaultVal" @keyup="saveSetting">
    </div>
</template>

<script>
import { mapState, mapMutations } from "vuex";
export default {
  data() {
    return {
      defaultVal: ""
    };
  },

  mounted() {
      this.defaultVal = this.setting[this.currSettingId].defaultVal;
  },

  computed: {
    ...mapState(["currSettingId", "setting"])
  },

  methods: {
    ...mapMutations(["SET_SETTING_INFO"]),

    saveSetting() {
      this.SET_SETTING_INFO({
        id: this.currSettingId,
        defaultVal: this.defaultVal
      });
    }
  },
  watch: {
    currSettingId() {
        this.defaultVal = this.setting[this.currSettingId].defaultVal;
    }
  }
};
</script>
